# =================conding: utf-8
"""
================================================================================

Author : Administrator
Created  on : 2020/11/22

E-mail: zh13997821732@163.com


================================================================================

"""

# 1.写一个循环，模拟用户登录的场景
# username = input('请输入你的姓名：')
# password = int(input('请输入你的密码：'))
# if username == '张浩' and password == 123456:
#     print('登录成功')
# else:
#     print('登录失败')

# 2.写一个循环，模拟地铁进站的场景（提示：先安检，才能进站，进站了买票了，才能乘车）
# a = '买票了'
# b = '安检'
# if b == '过安检':
#     print('通过了安检')
#     if a == '买票了':
#         print('请上车')
#     else:
#         print('没买票')
# else:
#     print('有危险品')

# 3.一直循环，控制台输入一个分数，然后打印对应的成绩等级  （非常优秀，优良中不及格），输入N，则停止循环
# a = int(input('你的成绩是：'))

# while True:
#     score = input('请输入分数：')
#     if score == 'N':
#         break
#     else:
#         score = int(score)
#     if score >= 90:
#         print('非常优秀')
#     elif score >= 80:
#         print('优')
#     elif score >= 70:
#         print('良')
#     elif score >= 60:
#         print('及格')
#     else:
#         print('不及格')

# 4.使用while循环实现九九乘法表
# i = 1
# while i <= 9:
#     j = 1
#     while j <= i:
#         print('{}*{}={}'.format(j, i, j * i), end='\t')
#         j += 1
#     print('')
#     i += 1

# 5.使用for循环实现九九乘法表
# for i in range(1,10) :
#     for j in range(1,i+1 ) :
#         if j <= i
#             print('{}*{}={}'.format(j,i,j*i), end ='\t')
#     print('')

# 6.有 1 2 3 4 这四个数字，能组成多少个互相不同且无重复数字的 3 位数，分别是什么
# a = [1, 2, 3, 4]
# count = 0
# for i in a:
#     for j in a:
#         for n in a:
#             if i != j and j != n and i != n:
#                 print('{}{}{}'.format(i, j, n))
#                 count += 1
# print(count)

# 排序算法 冒泡排序
# 7.利用 for 循环给列表  ls = [1,7,4,89,34,2,100,0] 从小到大排序
# ls = [1, 7 4, 89, 34, 2, 100, 0]
# ld = [1, 4, 7, 2, 34, 0, 89, 100]

def bubble_sort(ls1):
    for j in range(len(ls1)-1, 0, -1):
        for i in range(j):
            if ls1[i] > ls1[i+1]:
                ls1[i], ls1[i+1] = ls1[i+1], ls1[i]
    return ls1


a = [1, 7, 4, 0, -110, 89, 34, 2, 10000, 0, -1]
res = bubble_sort(a)
print(res)
# ls1 = [1, 2, 3, 4, 1, 4234, 5423, 54236, 645645]

